package com.sk.restree.model.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.sk.restree.model.dto.StatusDTO;
import com.sk.restree.model.ibatis.SqlMapFactory;

public class StatusDAO {
	private static StatusDAO instance;
	private SqlMapClient sqlMap;

	static {
		instance = new StatusDAO();
	}

	private StatusDAO() {
		sqlMap = SqlMapFactory.getSqlMapInstance();
	}

	public static StatusDAO getInstance() {
		return instance;
	}

	public List<StatusDTO> getUsedBenefitList(String member_id) {
		List<StatusDTO> list = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put("member_id", member_id);
		map.put("type", "benefit");
		try {
			list = sqlMap.queryForList("listBenefitStatus", map);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

	public List<StatusDTO> getSpendedList(String member_id) {
		List<StatusDTO> list = null;
		Map<String, String> map = new HashMap<String, String>();
		map.put("member_id", member_id);
		map.put("type", "fee");
		try {
			list = sqlMap.queryForList("listBenefitStatus", map);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

	public void insertBenefitStatus(String member_id, String name,
			String store_id) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("member_id", member_id);
		map.put("name", name);
		map.put("store_id", store_id);
		map.put("type", "benefit");
		try {
			sqlMap.insert("insertStatus", map);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void insertFeeStatus(String member_id, String name, String fee,
			String bank_id) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("member_id", member_id);
		map.put("name", name);
		map.put("bank_id", bank_id);
		map.put("fee", fee);
		map.put("type", "fee");
		try {
			sqlMap.insert("insertStatus", map);
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}
}
